********************************************************************************
*		Reproduction do file for: 											   *
*			Steiner, Nils D./Mader, Matthias/Schoen, Harald   				   * 
* 			Subjective Losers of Globalization								   *
* 			European Journal of Political Research       					   *
********************************************************************************


*** This do-file repoduces the results in the above-mentioned article. 

*** Instructrions:
// 1. To reproduce results, the survey data sets used will have to be downloaded directly from GESIS:
//  	Short-term Campaign Panel (GLES 2017), version 7.0.0, 2019-07-24 -> https://doi.org/10.4232/1.13323 
//		GLES Panel 2021, Wave 17, version 2.0.0 -> https://doi.org/10.4232/1.13935
// 2. Put these files (including the do-files for defining missing values) alongside the files that are part of our reproduction package (this do-file; dataset on electoral districts) into a single folder
// 3. Define this folder as the working directory 
// 4. Run the code below


**# Bookmark #1
********************************************************************************
******************* Settings and preparations **********************************
********************************************************************************
	clear all

*** install ados and schemes, if necessary:
	ssc install blindschemes, replace
	ssc install estout, replace
	ssc install coefplot, replace
	ssc install ciplot, replace
	ssc install fre, replace
	* install fitstat ado
		* search spost13_ado
		net from https://jslsoc.sitehost.iu.edu/stata/		
		net install spost13_ado, replace

*** graph settings
	set scheme plottig
	graph set window fontface "Times New Roman"

*** settings
	set maxvar 20000
	version 17.0

*** if necessary: set working directory to where the GLES Panel files from GESIS are stored
	capture cd "C:\Users\steinern\Dropbox\GlobLosers\Data"
	capture cd "C:\Users\NilsS\Dropbox\GlobLosers\Data"

	
**# Bookmark #2	
********************************************************************************	
******************************** Merge data set ********************************
********************************************************************************
*** Open GLES Campaign Panel data wave 17 and run missing do-file
	use "ZA7723_v2-0-0.dta"
	do "ZA7723_missing.do"
	save "ZA7723_v1-0-0_mv.dta", replace

*** Open GLES Campaign Panel data version 7 and run missing do-file
	clear all
	use "ZA6804_en_v7-0-0.dta"
	do "ZA6804_missing_en.do"

*** Merge wave 17 data to version 7 of the GLES campaign Panel
	merge 1:1 lfdn using "ZA7723_v1-0-0_mv.dta", gen(merge_w17)
	
*** Merge with data on electoral districts 
	// Data are from Bundeswahlleiter: https://www.bundeswahlleiter.de/bundestagswahlen/2017/strukturdaten.html
	* take first possibility for electoral district for those for which electoral districts is not clearly assignable
	replace elecdist17_=elecdist17_1 if elecdist17_>.
	merge m:1 elecdist17_ using "ElectionDistrictData_2017.dta"	

	
**# Bookmark #3
********************************************************************************
******************************** Recoding **************************************
********************************************************************************

******* Self-categorized globalization winner vs. loser *******
*** wave 9
	fre kp9_1260
	
	* categorical; don't know as missing
	recode kp9_1260 (1 2 3=0 "loser") (4=1 "midpoint") (.b=.b "don't know") (5 6 7=2 " winner"), gen(globwin_cat)
	label variable globwin_cat "globalization winner vs. loser"	
	
	* categorical; don't know as separate category
	recode kp9_1260 (1 2 3=0 "loser") (4=1 "midpoint") (5 6 7=2 "winner") (.b=3 "don't know") , gen(globwin_catDK)
	label variable globwin_catDK "globalization winner vs. loser"	
	
	* 1 to 7; don't know as missing
	recode kp9_1260 (1=1 "globalization loser") (7=7 "globalization winner") (.b=.b "don't know"), gen(globwin)
	label var globwin "globalization winner"	
	
	* 1 to 7; don't know as 9 (for plot only)
	recode kp9_1260 (1=1 "loser") (7=7 "winner") (.b=9 "don't know"), gen(globwin_dk)
	label variable globwin_dk "globalization winner vs. loser"	
	
	
*** wave 17
	* categorical; don't know as missing
	recode kp17_1260 (1 2 3=0 "loser") (4=1 "midpoint") (.b=.b "don't know") (5 6 7=2 " winner"), gen(globwin_cat_w17)
	label variable globwin_cat_w17 "globalization winner vs. loser, w17"

	* 1 to 7; don't know as missing
	recode kp17_1260 (1=1 "globalization loser") (7=7 "globalization winner") (.b=.b "don't know"), gen(globwin_w17)
	label var globwin_w17 "globalization winner"
	
	* Difference in globalization winner/loser Wave 9 vs wave 17
	gen globwinner_diff=globwin_w17-globwin
	

*** Socio-structural variables for classifying "objective" globalisation losers vs. winners ***
*** Education
	* School leaving certificate
	fre kp9_2320
	recode kp9_2320 (1 2 = 1) (3 = 2) (4 = 3) (5 = 4) (9 = .), gen(educat)
	* Vocational and professional training
	clonevar voctraining=kp1_2330
	replace voctraining=kpa1_2330 if voctraining>.
	
	replace educat=5 if voctraining==9
	replace educat=6 if voctraining==10
	
	label define educat ///
		1 "low school degree" ///
		2 "lower-middle school degree"  ///
		3 "upper-middle school degree" ///
		4 "high school degree" ///
		5 "polytechnic degree" ///
		6 "university degree" 
	label values educat educat		
	
	
*** Income 
	fre kp1_2591
	clonevar inc_raw=kp1_2591
	replace inc_raw=kpa1_2591 if inc_raw>.	
	* recode inc_raw (1 2 3 = 1 "income <1000€") (4 5 6 = 2 "income 1000-2000€") (7 8 = 3 "income 2000-3000€") (9 = 4 "income 3000-4000€") (10 11 12 13 14 = 5 "income >4000€"), gen(incomecat)	

	* Compute equivalence income: income divided by adjusted household size
		* modified OECD equivalence scale
		* see: https://ec.europa.eu/eurostat/statistics-explained/index.php?title=Glossary:Equivalised_disposable_income#:~:text=The%20equivalised%20disposable%20income%20is,according%20to%20their%20age%2C%20using
		* people in household
		clonevar hhmember=kp1_2441
		replace hhmember=kpa1_2441 if hhmember>=.
		* children in household (note that this counts people under 18, whereas boundary is actually 14 in OECD formula)
		clonevar hhchildren=kp1_2450
		replace hhchildren=kpa1_2450 if hhchildren>=.
		replace hhchildren=0 if hhmember==1		

		* adults in household
		gen hhadult=hhmember-hhchildren
		
		* equivalised household size
		gen hhsize=1+(hhadult-1)*0.5+hhchildren*0.3
	
		* make a continuous variable out of the categorical income variable by using means of brackets 
		gen income_numb=250 if inc_raw==1
		replace income_numb=625 if inc_raw==2
		replace income_numb=875 if inc_raw==3
		replace income_numb=1125 if inc_raw==4
		replace income_numb=1375 if inc_raw==5
		replace income_numb=1750 if inc_raw==6
		replace income_numb=2250 if inc_raw==7
		replace income_numb=2750 if inc_raw==8
		replace income_numb=3500 if inc_raw==9
		replace income_numb=4500 if inc_raw==10
		replace income_numb=6250 if inc_raw==11
		replace income_numb=8750 if inc_raw==12
		replace income_numb=11000 if inc_raw==13

	* divided numerical income by adjusted household size
	gen income_equi=income_numb/hhsize

	* recode into income categories
	recode income_equi (0/499=0 "income <500€") (500/999=1 "income 550-999€") ///
				(1000/1499=2 "income 1000-1499€") (1500/1999=3 "income 1500-1999€") ///
				(2000/2499=4 "income 2000-2499€") (2500/2999=5 "income 2500-2999€") ///
				(3000/10000000000=6 "income >3000€"), gen(incomecat)
		fre incomecat

		
*** Occupational classes
	* current profession
	fre kp1_2380
	clonevar profession=kp1_2380
	fre profession
	replace profession=kpa1_2380 if profession>=.	
	fre profession

	* replace profession with former profession if current missing
	replace profession=kpx_2390 if profession>=.	
	fre profession

	capture drop occupclass
	recode profession (6=0 "worker") (1 3 8=2 "self-employed") (5=3 "employee") (4=6 "civil servant") (2=8 "independent professional") (7=10 "in vocational training"), gen(occupclass)
	fre occupclass

	* differentation worker
	clonevar workertype_raw=kp1_3620
	replace workertype_raw=kpa1_3620 if workertype_raw>=.
	replace workertype_raw=kpx_3720 if workertype_raw>=.

	recode workertype_raw (1=0 "low-skilled worker") (2 3=1 "skilled worker"), gen(workertype)

	replace occupclass=0 if occupclass==0 & workertype==0
	replace occupclass=1 if occupclass==0 & workertype==1
	replace occupclass=. if occupclass==0 & workertype>=.
	
	* differentation employee
	clonevar employeetype_raw=kp1_3610
	replace employeetype_raw=kpa1_3610 if employeetype_raw>=.
	replace employeetype_raw=kpx_3710 if employeetype_raw>=.

	recode employeetype_raw (1 2=0 "employee, simple tasks") (3=1 "employee, complex tasks") (4 5=2 "employee, managerial"), gen(employeetype)

	replace occupclass=3 if occupclass==3 & employeetype==0
	replace occupclass=4 if occupclass==3 & employeetype==1
	replace occupclass=5 if occupclass==3 & employeetype==2
	replace occupclass=. if occupclass==3 & employeetype>=.

	* differentation civil servant
	clonevar civiltype_raw=kp1_3640
	replace civiltype_raw=kpa1_3640 if civiltype_raw>=.
	replace civiltype_raw=kpx_3740 if civiltype_raw>=.

	recode civiltype_raw (1 2=0 "lower grade") (2 3=1 "upper grade"), gen(civiltype)

	replace occupclass=6 if occupclass==6 & civiltype==0
	replace occupclass=7 if occupclass==6 & civiltype==1
	replace occupclass=. if occupclass==6 & civiltype>=.

	* differentation independent
	clonevar independenttype_raw=kp1_3630
	replace independenttype_raw=kpa1_3630 if independenttype_raw>=.
	replace independenttype_raw=kpx_3730 if independenttype_raw>=.

	recode independenttype_raw (1=0 "no employees") (2 3=1 "with employees"), gen(independenttype)

	replace occupclass=8 if occupclass==8 & independenttype==0
	replace occupclass=9 if occupclass==8 & independenttype==1
	replace occupclass=. if occupclass==8 & independenttype>=.	
	
	label define occupclass 0 "low-skilled worker" 1 "skilled worker" ///
			2 "self-employed" ///
			3 "employee, simple" 4 "employee, complex" 5 "employee, managerial" ///
			6 "civil servant, lower" 7 "civil servant, upper"  ///
			8 "ind. prof., w/o empl." 9 "ind. prof., w. empl." ///		
			10 "in vocational training" , replace
	fre occupclass

	
*** Sector of employment
	clonevar sector_raw= kp1_3660
	replace sector_raw=kpx_3760 if sector>=.
	recode sector_raw (12=14 "education & research") (11=13 "administration") (9=12 "IT") (8=11 "banking & insurance") (10=10 "commercial services") (3=9 "manufacturing") ///
						(5=8 "trade") (13=7 "social services") (7=6 "transport") (6=5 "hotel & catering") (4=4 "construction") (14=3 "other services") (1=2 "agriculture") (2=1 "energy & water"), gen(sector) 
	fre sector

		
	* Second version: code the sector variable to a unique, non-missing value for all respondents who are part of the refreshment wave 
	
	clonevar sector2=sector
	replace sector2=0 if sample==3
		* (to whom this question was not asked and who we want to still include in the latter part of the analysis) 
	label define sector 0 "refreshment sample (missing)", add
	tab sample sector2
	
	
*** Regional-level variables
	* standardize local index to range from zero to one
	sum local_index
	gen local_index_st = (local_index + -1*r(min)) / (-1*r(min) + r(max))
	sum local_index_st	
	label variable local_index_st "socio-econ. sit. (district)"
					
	* log population density and standardize to range from zero to one
	gen popdensity_log=ln(popdensity)
	sum popdensity_log
	gen popdensity_log_st = (popdensity_log + -1*r(min)) / (-1*r(min) + r(max))

	
******* Other sociodemographic variables *******

*** Age
	gen age=2018-kpx_2290
	recode age (18/34=0 "18 to 34") (35/49=1 "35 to 49") (50/64=2 "50 to 64") (65/120=3 "65+"), gen(agegroup)
	
	recode age (18/29=0 "18 to 29") (30/39=1 "30 to 39") (40/49=2 "40 to 49") (50/59=3 "50 to 59") (60/69=4 "60 to 69") (70/130=5 "70+"), gen(agegroup_fine)

*** Gender
	fre kpx_2280
	recode kpx_2280 (2 = 1 "female") (1 = 0 "male"), gen(female)

*** State of residence:  East vs. West
	recode ostwest (-95 = .d) (0 = 1 "East Germany") (1 = 0 "West Germany"), gen(east)
	
*** Migration background 
	* respondent born on current German territory -> 0
	gen migrationbackground=0 if kpx_3920>=1 & kpx_3920<=16
	* respondent born on Former German territories in Eastern Europe (e.g. East Prussia, Silesia) -> 0
	replace migrationbackground=0 if kpx_3930==1
	* respondent born in other country -> 1
	replace migrationbackground=1 if kpx_3930>=2 & kpx_3930<=16
	* father born in other country -> 1
	replace migrationbackground=1 if kpx_2572b>=2 & kpx_2572b<=16
	* mother born in other country -> 1
	replace migrationbackground=1 if kpx_2572a>=2 & kpx_2572a<=16
		
*** Unemployed
	fre kp1_2340 kpa1_2340
	clonevar emp_raw=kp1_2340
	replace emp_raw=kpa1_2340 if emp_raw>.
	recode emp_raw (7=1 "unemployed") (1 2 3 4 5 6 8 9 10 11 12=0 "not unemployed"), gen(unemployment)
	replace unemployment=0 if kp9_2320==9 // those still in school -> not unemployed

*** States: dummy variable 
	tab state, gen(state_dum)


******* Issue attitudes *******	
	* Attitudes towards globalization (in wave 9)
	fre kp9_2880v
	clonevar globw9 = kp9_2880v
	lab var globw9 "Globalisierung eine gute Sache"
	label define globw9 ///
	1 "disagree completely" ///
	2 "disagree" ///
	3 "partly disagree, partly agree" ///
	4 "agree" ///
	5 "agree completely"
	label values globw9 globw9
	gen globalizationbad=-globw9
	
	* Other variables
	gen marketintegrationnot=-kp9_2880ag	
	clonevar restrictimports=kp9_2880ah
	gen foreigncompaniesnotinvest=-kp9_2880ai
	
	clonevar EUunificationtoofar=kp8_1250
	clonevar EUunificationtoofar_w7=kp7_1250
	clonevar EUunificationtoofar_w6=kp6_1250

	clonevar refugeelimit=kp9_2880x
	clonevar econrefugeesdeport=kp8_2880b
	clonevar restrictimmigration=kp8_1130
	gen foreignersassimilate=-kp8_1210
	
	clonevar moresocialservices=kp8_1090
	clonevar richhighertaxes=kp8_2880j
	clonevar reduceincomediffs=kp7_2880d
	
	clonevar Growthoverclimate=kp8_1290
	gen keeppetroldiesel=-kp8_2880w
	
	gen Securityoverprivacy=-kp8_1411
	gen fightcrime=kp9_2880h
	
	gen nohomoadoption=-kp4_2880a
	
	* Standardize to range from zero to one
	foreach var of varlist  globalizationbad ///
							marketintegrationnot restrictimports foreigncompaniesnotinvest ///
							EUunificationtoofar EUunificationtoofar_w7 EUunificationtoofar_w6 ///
							refugeelimit econrefugeesdeport restrictimmigration foreignersassimilate ///
							richhighertaxes reduceincomediffs moresocialservices ///
							Growthoverclimate keeppetroldiesel ///
							Securityoverprivacy fightcrime ///
							nohomoadoption {
	sum `var'
	gen `var'_std=(`var'-r(min))/(r(max)-r(min))
	}
	
	*** Mean indices
	gen globecon_mean=(marketintegrationnot_std+restrictimports_std+foreigncompaniesnotinvest_std)/3
	gen EUunificationtoofar_mean=(EUunificationtoofar_std+EUunificationtoofar_w6_std+EUunificationtoofar_w7_std)/3
	gen globimmi_mean=(refugeelimit_std+econrefugeesdeport_std+restrictimmigration_std+foreignersassimilate_std)/4
	gen redistribution_mean=(moresocialservices_std+reduceincomediffs_std+richhighertaxes_std)/3

	
******* Voting and party preferences *******	
	
*** Voting intention
	* seperate code for no intention to vote (for descriptive results)
	clonevar voteint_w9=kp9_190ba
	label variable voteint_w9 "voting intention"
	replace voteint_w9=999 if kp9_170==4 |  kp9_170==5
	label define KP9_190BA 999 `"no intention to vote"', add
	recode voteint_w9 (1=1 "Union") (6=2 "Greens") (4=3 "SPD") (5=4 "FDP") (7=5 "Left") (322=6 "AfD") (801=7 "other") (999=8 "no"), gen(voteint_w9_ord)

	* variable for regression analysis; numbered; no intention -> missing 
	recode voteint_w9 (1=1 "CDU/CSU") (6=2 "Greens") (4=3 "SPD") (5=4 "FDP") (7=5 "The Left") (322=6 "AfD") (801=7 "other") (999=.), gen(voteint_w9_numb)

*** Reported vote choice
	* recalled vote choice in wave 8 (voting in presence)
	clonevar voterecall=kp8_200ba
	
	* replace with recall information from wave 9 (if missing)
	replace voterecall=kp9_200ba if voterecall>. & kp9_200ba!=.	
	
	* replace with postal vote for postal voters (if missing)
	replace voterecall=kp5_191ba if voterecall>. & kp5_191ba!=.
	replace voterecall=kp6_191ba if voterecall>. & kp6_191ba!=.
	replace voterecall=kp7_191ba if voterecall>. & kp7_191ba!=.
	replace voterecall=kp8_191ba if voterecall>. & kp8_191ba!=.
	replace voterecall=kp9_191ba if voterecall>. & kp9_191ba!=.
 	
	* final variable vor vote choice (excluding non-voters)
	recode voterecall (1=1 "Union") (6=2 "Greens") (4=3 "SPD") (5=4 "FDP") (7=5 "The Left") (322=6 "AfD") (801=7 "other"), gen(voterecall_num)   
	
	* create dummy variable for "did not vote" (from questions in wave 8 and, if missing, wave 9)
	recode kp8_180 (1=0) (6=0) (2=1), gen(kp8_nonvote)
	recode kp9_180 (1=0) (6=0) (2=1), gen(kp9_nonvote)
	clonevar nonvote=kp8_nonvote
	replace nonvote=kp9_nonvote if nonvote>.
	
	* final variable for vote choice with not voting as category (i.e. including non-voters)
	clonevar voterecall2_num = voterecall_num
	replace voterecall2_num = 8 if nonvote == 1
	label copy voterecall_num voterecall_num2
	lab def voterecall_num2 8 "not vote", modify
	label values voterecall2_num voterecall_num2

	
******* Deprivation and subjective social class *******	
*** Subjective social class
	fre kp1_2580 kpa1_2580
	clonevar subjclass_raw=kp1_2580
	replace subjclass_raw=kpa1_2580 if subjclass_raw>.
	recode subjclass_raw (1 2=0 "lower and working class") (3=1 "lower middle class") (4=2 "middle class") (5 6=3 "upper (middle) class"), gen(subjclass)
										
*** Subjective deprivation		
	recode kp9_2270 (1 2=1 "more than fair share") (3=2 "fair share") (4=3 "bit less than fair share") (5=4 "lot less than fair share"), gen(subjdeprivation)
	label variable subjdeprivation "subjdeprivation"	
		
	
******* Create weight based on post-stratification weight provided and recalled vote in 2017 election *******

	*** combine poststratification weights (adjusting to Microzensus 2016) in one variable 
		sum wei2_mz wei3_mz
	
		* regular sample plus re-contact sample 
		gen psweight=wei2_mz
		* 2017 refreshment sample
		replace psweight=wei3_mz if psweight!=.
	
	*** create weight based on voting behavior
		* create totals in population (vote totals from official statistics for Bundestagswahl 2017)
		* CDU/CSU
		gen voterecall2_num_tot=15317344 if voterecall2_num==1		
		* Greens
		replace voterecall2_num_tot=4158400 if voterecall2_num==2
		* SPD
		replace voterecall2_num_tot=9539381 if voterecall2_num==3
		* FDP
		replace voterecall2_num_tot=4999449 if voterecall2_num==4
		* The Left
		replace voterecall2_num_tot=4297270 if voterecall2_num==5
		* AfD
		replace voterecall2_num_tot=5878115 if voterecall2_num==6
		* other
		replace voterecall2_num_tot=2167115 if voterecall2_num==7
		* eligible but did not vote
		replace voterecall2_num_tot=14712144 if voterecall2_num==8

		*** create the weights based on the two poststratification weights
		* regular sample plus re-contact sample
		survwgt post wei2_mz, by(voterecall2_num) totvar(voterecall2_num_tot) gen(voteweight1)
		* normalize
		sum voteweight1
		replace voteweight1=voteweight1/(r(mean))
		sum voteweight1
		* 2017 refreshment sample
		survwgt post wei3_mz, by(voterecall2_num) totvar(voterecall2_num_tot) gen(voteweight2)
		* normalize
		sum voteweight2
		replace voteweight2=voteweight2/(r(mean))
		sum voteweight2
		* combine the two in one variable
		gen voteweight=voteweight1
		replace voteweight=voteweight2 if voteweight==.
		sum voteweight
	
	*** Multiply weight (to use as fweight, where only integer values are accepted)
		gen voteweight_mult=100000000*voteweight
		
	*** test weight
	  svyset [pweight=wei2_mz]
		svy: proportion voterecall_num

	  svyset [pweight=voteweight]
		svy: proportion voterecall_num

save "GLES Panel 2017_merged.dta", replace

* use "GLES Panel 2017_merged.dta"


**# Bookmark #4	
********************************************************************************	
*********** Descriptive results on self-categorization *************************
********************************************************************************	
	
**** FIGURE 2: Histogram: Globalization loser vs. winner (with don't know)
	tab globwin_dk
	svy: proportion globwin_dk

	* original scale 
	hist globwin_dk [fweight=voteweight_mult], percent discrete xlabel(1 "loser" 2 3 4 5 6 7 "winner" 9 "don't know", angle(045)) ///
		xtitle(" ", size(zero)) ///
		addlabopts(yvarformat(%4.0f) mlabsize(small)) name(gr1, replace) nodraw
	
	* categorical
	hist globwin_catDK [fweight=voteweight_mult], percent discrete xlabel(0 1 2 4, valuelabel angle(045)) ///
		xtitle(" ", size(zero)) ///
		addlabopts(yvarformat(%4.0f) mlabsize(small)) name(gr2, replace) nodraw
	
	graph combine gr1 gr2, ycommon imargin(vsmall) iscale(*2.4) xsize(9) note("n=12,005", size(medium)  pos(5)) name(Figure2, replace)
		graph export "Figure2.pdf", replace

**** APPENDIX B: Stability of self-categorizations (Globalization loser vs. winner: wave 9 vs. wave 17)
	* Figure B1: Scatterplot of globalization loser vs. winner in March 2018 and July 2021
	pwcorr globwin_w17 globwin
	twoway (scatter globwin_w17 globwin, jitter(12) msymbol(.) msize(tiny)) (lfit globwin_w17 globwin), ///
		xlabel(1/7) ylabel(1/7) xtitle("Globalisation loser vs. winner (March 2018)") ytitle("Globalisation loser vs. winner (July 2021)") scale(*1.4) legend(off) ///
		name(FigureB1, replace) 	
		
	* Figure B2: Scatterplot of globalization loser vs. winner in March 2018 and July 2021
	sum globwinner_diff
	fre globwinner_diff
	hist globwinner_diff [fweight=voteweight_mult], discrete percent xlabel(-6 (1) 6) addlabel addlabopts(yvarformat(%4.1f)) scale(*1.4) ///
		xtitle("Globalization winner/loser in July 2021 - Globalization winner/loser in March 2018") ///
		name(FigureB2, replace) 	
		
	
**# Bookmark #5
*****************************************************************************************							
**** Regression: Social structure -> Self-categorized globalisation loser vs. winner ****
*****************************************************************************************				

***** Main structural individual-level variables in four different models *****
*** Predicted probabilities for globalization loser and winner
			* ordered logit regression with education
			ologit globwin_cat i.female i.agegroup i.east i.unemployment i.educat [pweight=voteweight]
				fitstat
				eststo reg
				* probability of loser
				margins, predict(outcome(0)) at(educat=(1/6)) post
				eststo loser
					
				* probability of winner
				estimates restore reg
				margins, predict(outcome(2)) at(educat=(1/6)) post
				eststo winner
									
				coefplot ///
					(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
					(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
					note("n=9,374, McKelvey & Zavoina R²=0.087", size(vsmall) position(5)) ///
					coeflabel(1._at="low schooling" 2._at="lower-middle schooling" 3._at="upper-middle schooling" ///
						4._at="high schooling" 5._at="polytechnic degree" 6._at="university degree") ///
					xlabel(.1 (.1) .7, gmin gmax) ///
					legend(off) ///
					text(6.05 .15 "Loser", color(orange_red) size(small)) ///
					text(5.85 .55 "Winner", color(dknavy) size(small)) ///
					name(edu, replace) nodraw			
			
		   * ordered logit regression with income
			ologit globwin_cat i.female i.agegroup i.east i.unemployment i.incomecat [pweight=voteweight]
				fitstat
				eststo reg
				
				* probability of loser
				margins, predict(outcome(0)) at(incomecat=(0/6)) post
				eststo loser
					
				* probability of winner
				estimates restore reg
				margins, predict(outcome(2)) at(incomecat=(0/6)) post
				eststo winner
									
				coefplot ///
					(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
					(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
					note("n=9,303, McKelvey & Zavoina R²=0.098", size(vsmall) position(5)) ///
					coeflabel(1._at="income <500€" 2._at="income 550-999€" 3._at="income 1000-1499€" 4._at="income 1500-1999€" 5._at="income 2000-2499€" 6._at="income 2500-2999€" 7._at="income >3000€") ///
					xlabel(.1 (.1) .7) ///
					legend(off) ///
					name(inc, replace) nodraw			

		   * ordered logit regression with occupational class
			ologit globwin_cat i.female i.agegroup i.east i.unemployment i.occupclass [pweight=voteweight]
				fitstat	
				eststo reg
					
				* probability of loser
				margins, predict(outcome(0)) at(occupclass=(0/9)) post
				eststo loser
					
				* probability of winner
				estimates restore reg
				margins, predict(outcome(2)) at(occupclass=(0/9)) post
				eststo winner
									
				coefplot ///
					(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
					(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
					note("n=9,071, McKelvey & Zavoina R²=0.068", size(vsmall) position(5)) ///
					coeflabel(1._at="low-skilled worker" 2._at="skilled worker" 3._at="self-employed" 4._at="employee, simple" 5._at="employee, complex" ///
							 6._at="employee, managerial" 7._at="civil servant, lower" 8._at="civil servant, upper" 9._at="ind. prof., w/o empl." 10._at="ind. prof., w. empl.") ///
					xlabel(.1 (.1) .7) ///
					legend(off)	///
					name(occ, replace) nodraw		

						// individuals in vocational training omitted from plot

			* ordered logit regression with sector
			ologit globwin_cat i.female i.agegroup i.east i.unemployment i.sector [pweight=voteweight]
				fitstat
				eststo reg
				
				* probability of loser
				margins, predict(outcome(0)) at(sector=(1/14)) post
				eststo loser
					
				* probability of winner
				estimates restore reg
				margins, predict(outcome(2)) at(sector=(1/14)) post
				eststo winner
									
				coefplot ///
					(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
					(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
					note("n=7,293, McKelvey & Zavoina R²=0.050", size(vsmall) position(5)) ///
					coeflabel(1._at="energy & water" 2._at="agriculture" 3._at="other services" 4._at="construction" 5._at="hotel & catering" ///
							 6._at="transport" 7._at="social services" 8._at="trade" 9._at="manufacturing" 10._at="commercial services" ///
							 11._at="banking & insurance" 12._at="IT" 13._at="administration" 14._at="education & research") ///
					xlabel(.1 (.1) .7, gmin gmax) ///
					legend(off)	///
					name(sec, replace) nodraw		
				
			* Figure 3: Social structure and self-categorization as loser and as winner of globalization
			* combine graphs	
			graph combine edu occ inc sec, iscale(*1.3) ysize(5) imargin(small) name(Figure3, replace)				
				graph export "Figure3.pdf", replace

			
			/*
					*** with migration background (robustness check; only for review process)
								* ordered logit regression with education
					ologit globwin_cat i.female i.agegroup i.east i.unemployment i.educat i.migrationbackground [pweight=voteweight]
						fitstat
						eststo reg
						* probability of loser
						margins, predict(outcome(0)) at(educat=(1/6)) post
						eststo loser
							
						* probability of winner
						estimates restore reg
						margins, predict(outcome(2)) at(educat=(1/6)) post
						eststo winner
											
						coefplot ///
							(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
							(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
							note("n=7,550, McKelvey & Zavoina R²=0.085", size(vsmall) position(5)) ///
							coeflabel(1._at="low schooling" 2._at="lower-middle schooling" 3._at="upper-middle schooling" ///
								4._at="high schooling" 5._at="polytechnic degree" 6._at="university degree") ///
							xlabel(.1 (.1) .7, gmin gmax) ///
							legend(off) ///
							text(6.05 .15 "Loser", color(orange_red) size(small)) ///
							text(5.85 .55 "Winner", color(dknavy) size(small)) ///
							name(edu, replace)			
					
				   * ordered logit regression with income
					ologit globwin_cat i.female i.agegroup i.east i.unemployment i.incomecat i.migrationbackground [pweight=voteweight]
						fitstat
						eststo reg
						
						* probability of loser
						margins, predict(outcome(0)) at(incomecat=(0/6)) post
						eststo loser
							
						* probability of winner
						estimates restore reg
						margins, predict(outcome(2)) at(incomecat=(0/6)) post
						eststo winner
											
						coefplot ///
							(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
							(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
							note("n=7,436, McKelvey & Zavoina R²=0.091", size(vsmall) position(5)) ///
							coeflabel(1._at="income <500€" 2._at="income 550-999€" 3._at="income 1000-1499€" 4._at="income 1500-1999€" 5._at="income 2000-2499€" 6._at="income 2500-2999€" 7._at="income >3000€") ///
							xlabel(.1 (.1) .7) ///
							legend(off) ///
							name(inc, replace)			

				   * ordered logit regression with occupational class
					ologit globwin_cat i.female i.agegroup i.east i.unemployment i.occupclass i.migrationbackground [pweight=voteweight]
						fitstat	
						eststo reg
							
						* probability of loser
						margins, predict(outcome(0)) at(occupclass=(0/9)) post
						eststo loser
							
						* probability of winner
						estimates restore reg
						margins, predict(outcome(2)) at(occupclass=(0/9)) post
						eststo winner
											
						coefplot ///
							(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
							(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
							note("n=7,278, McKelvey & Zavoina R²=0.068", size(vsmall) position(5)) ///
							coeflabel(1._at="low-skilled worker" 2._at="skilled worker" 3._at="self-employed" 4._at="employee, simple" 5._at="employee, complex" ///
									 6._at="employee, managerial" 7._at="civil servant, lower" 8._at="civil servant, upper" 9._at="ind. prof., w/o empl." 10._at="ind. prof., w. empl.") ///
							xlabel(.1 (.1) .7) ///
							legend(off)	///
							name(occ, replace)		

								// individuals in vocational training omitted from plot

					* ordered logit regression with sector
					ologit globwin_cat i.female i.agegroup i.east i.unemployment i.sector i.migrationbackground [pweight=voteweight]
						fitstat
						eststo reg
						
						* probability of loser
						margins, predict(outcome(0)) at(sector=(1/14)) post
						eststo loser
							
						* probability of winner
						estimates restore reg
						margins, predict(outcome(2)) at(sector=(1/14)) post
						eststo winner
											
						coefplot ///
							(loser, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
							(winner, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
							note("n=7,293, McKelvey & Zavoina R²=0.050", size(vsmall) position(5)) ///
							coeflabel(1._at="energy & water" 2._at="agriculture" 3._at="other services" 4._at="construction" 5._at="hotel & catering" ///
									 6._at="transport" 7._at="social services" 8._at="trade" 9._at="manufacturing" 10._at="commercial services" ///
									 11._at="banking & insurance" 12._at="IT" 13._at="administration" 14._at="education & research") ///
							xlabel(.1 (.1) .7, gmin gmax) ///
							legend(off)	///
							name(sec, replace)		
						
					* combine graphs	
					graph combine edu occ inc sec, iscale(*1.3) ysize(5) imargin(small) name(probLWoG, replace)				
			
			
			
		*** interaction between income and education 
					* ordered logit regression with education X income interaction
					ologit globwin_cat i.female i.agegroup i.east i.unemployment i.educat##i.incomecat [pweight=voteweight]
						fitstat
						eststo reg
						
						* probability of loser
						margins, predict(outcome(0)) at(incomecat=(0/6) educat=(1/6)) post
						eststo loser
						mplotoffset, recast(scatter) ytitle("Predicted probability") title("Predicted probability of self-categorization as globalization loser") ///
							xtitle(" ") xlabel( , angle(015)) name(interact_incedu_loser, replace)					
							
						* probability of winner
						estimates restore reg
						margins, predict(outcome(2)) at(incomecat=(0/6) educat=(1/6)) post
						eststo winner
						mplotoffset, recast(scatter) ytitle("Predicted probability") title("Predicted probability of self-categorization as globalization winner") ///
							xtitle(" ") xlabel( , angle(015)) name(interact_incedu_winner, replace)
		
						graph combine interact_incedu_loser interact_incedu_winner, col(1) xcommon iscale(*1.2) imargin(tiny)
						
			*/											
	
	
***** Appendix C: Additional results for socio-structural roots of self-categorization *****
	
*** Structural individual-level variables in one model
	* regression model
	ologit globwin_cat i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 [pweight=voteweight]
		fitstat
		eststo reg

		* Figure C1: Average marginal effects on the probability to self-categorize as globalization loser from full model
		margins, dydx(*) predict(outcome(0)) post
		coefplot, level(95 85) ciopts(color(orange_red orange_red)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(orange_red) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=8,968; McKelvey & Zavoina R²=0.125") ysize(6) ///
			name(FigureC1, replace)			
			
		* Figure C2: Average marginal effects on the probability to self-categorize as globalization winner from full model
		estimates restore reg
		margins, dydx(*) predict(outcome(2)) post
		coefplot, level(95 85) ciopts(color(dknavy dknavy)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(dknavy) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=8,968; McKelvey & Zavoina R²=0.125") ysize(6) ///
			name(FigureC2, replace)			
	
		
*** Multinomial logit with self-categorization as globalization loser vs. winner as dependent variable  
	* regression model
	mlogit globwin_catDK i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 [pweight=voteweight]
		fitstat
		eststo reg

		* Figure C3: Average marginal effects on the probability to self-categorize as globalization loser from multinomial logit
		margins, dydx(*) predict(outcome(0)) post
		coefplot, level(95 85) ciopts(color(orange_red orange_red)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(orange_red) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=10,863; McFadden R²=0.066") ysize(6) ///
			name(FigureC3, replace)		
		
		* Figure C4: Average marginal effects on the probability to self-categorize in the middle of the globalization loser vs. winner scale from multinomial logit
		estimates restore reg
		margins, dydx(*) predict(outcome(1)) post
		coefplot, level(95 85) ciopts(color(black black)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(black) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=10,863; McFadden R²=0.066") ysize(6) ///
			name(FigureC4, replace)		
			
		* Figure C5: Average marginal effects on the probability to answer don't know on the globalization loser vs. winner question from multinomial logit
		estimates restore reg
		margins, dydx(*) predict(outcome(3)) post
		coefplot, level(95 85) ciopts(color(gs10 gs10)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(gs10) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=10,863; McFadden R²=0.066") ysize(6) ///
			name(FigureC5, replace)		
			
		* Figure C6: Average marginal effects on the probability to self-categorize as globalization winner from multinomial logit
		estimates restore reg
		margins, dydx(*) predict(outcome(2)) post
		coefplot, level(95 85) ciopts(color(dknavy dknavy)) xlabel(-0.2 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(dknavy) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=10,863; McFadden R²=0.066") ysize(6) ///
			name(FigureC6, replace)			

			
*** Figure C7: Regression coefficients from linear regression for self-categorization on 1 to 7 scale
	reg globwin i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 [pweight=voteweight]			
	coefplot, level(95 85) ciopts(color(dknavy dknavy))  ///
			baselevels msymbol(+) mcolor(dknavy) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			xsize(4.5) xline(0) note("n=8,968; R²=0.117") ysize(6) ///
			drop (_cons) ///
			name(FigureC7, replace)			



***** Regional socio-economic situation and self-categorization as loser and as winner of globalization *****
	clear
	use "ElectionDistrictData_2017.dta", replace

	* Table A2: Principal component analysis of socio-economic conditions at the district level
	pca birthbalance dispincome_log gdppc_log unemploymentrate empl_socialinsurance
		predict local_index2	
		pwcorr local_index local_index2
	
	clear
	use "GLES Panel 2017_merged.dta"
	
	*** Multilevel ordered logit models for self-categorization as globalization winner/loser with socio-economic situation in electoral district
		* model without level 1-predictors 
		meologit globwin_cat ///
			local_index_st state_dum*  ///
			|| elecdist17_:	
		
		eststo mlolog_empty
		
		* model with level 1-predictors 
		meologit globwin_cat i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2  ///
			local_index_st state_dum* ///
			|| elecdist17_: ,	
						
		eststo mlolog_full		
		
		* with control for population density
			* model without level 1-predictors 
			meologit globwin_cat ///
				local_index_st popdensity_log_st state_dum*  ///
				|| elecdist17_:	
			
			eststo mlolog_empty2
			
			* model with level 1-predictors 
			meologit globwin_cat i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2  ///
				local_index_st  popdensity_log_st state_dum* ///
				|| elecdist17_: ,	
							
			eststo mlolog_full2		
		
			* Table C1: Multilevel ordered logit models for self-categorization as globalization winner/loser with socio-economic situation in electoral district
			esttab  mlolog_empty mlolog_full mlolog_empty2 mlolog_full2 using "TableC1.rtf", b(a2) se(a2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
				nogaps compress ///
				order(local_index_st popdensity_log_st) ///
				label replace
				
		* Figures with predicted probabilities
		* model WITHOUT level 1-predictors 

			* loser probability
			estimates restore mlolog_empty
			margins, at(local_index_st=(0 (0.1) 1)) predict(outcome(0)) post
			eststo localpredloser_empty	
			
			* winner probability
			estimates restore mlolog_empty
			margins, at(local_index_st=(0 (0.1) 1)) predict(outcome(2)) post
			eststo localpredwinner_empty	
			
			coefplot ///
				(localpredloser_empty, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
				(localpredwinner_empty, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
				note("individuals=9,589; electoral districts=299", size(vsmall) position(5)) ///
				xlabel(.15 (.05) .55, gmin gmax) ///
				coeflabel(1._at="0" 2._at=".1" 3._at=".2" 4._at=".3" 5._at=".4" 6._at=".5" 7._at=".6" 8._at=".7" 9._at=".8" 10._at=".9" 11._at="1") ///
				text(1 .2 "Loser", color(orange_red) size(small)) ///
				text(1 .4 "Winner", color(dknavy) size(small)) ///
				legend(off) ///
				title(without individual-level variables) ///
				name(empty, replace) nodraw
	
		* model WITH level 1-predictors 

			* loser probability
			estimates restore mlolog_full
			margins, at(local_index_st=(0 (0.1) 1)) predict(outcome(0)) post
			eststo localpredloser_full	
			
			* winner probability
			estimates restore mlolog_full
			margins, at(local_index_st=(0 (0.1) 1)) predict(outcome(2)) post
			eststo localpredwinner_full	
				
			coefplot ///
				(localpredloser_full, msymbol(+) mcolor(orange_red) level(95 85) ciopts(color(orange_red orange_red))) ///
				(localpredwinner_full, msymbol(+) mcolor(dknavy) level(95 85) ciopts(color(dknavy dknavy))), ///
				note("individuals=9,105; electoral districts=299", size(vsmall) position(5)) ///
				xlabel(.15 (.05) .55, gmin gmax) ///
				coeflabel(1._at="0" 2._at=".1" 3._at=".2" 4._at=".3" 5._at=".4" 6._at=".5" 7._at=".6" 8._at=".7" 9._at=".8" 10._at=".9" 11._at="1") ///
				legend(off) ///
				title(with individual-level variables) ///
				name(full, replace) nodraw
		
		* Figure 4: Regional socio-economic situation and self-categorization as loser and as winner of globalization
		* combine to one graph
		graph combine empty full, xsize(8) iscale(*2.2) name(Figure4, replace)
			graph export "Figure4.pdf", replace

		
***** Table 1: Objective vs. subjective (self-categorized) losers and winners of globalization *****
	* Predicted values vs. self-categorization	
	* run simple ordered logit model with only the structural winner vs. loser vars 
	ologit globwin_cat ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 local_index 
	
		eststo olog_classification

		* Regression table
		esttab  olog_classification using olog_classif_Table.rtf, b(a2) se(a2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
				nogaps compress ///
				label replace		
	
		* obtain predicted probabilities for loser and winner
		predict loserprob if e(sample), pr outcome(0)
		predict winnerprob if e(sample), pr outcome(2)
		
		* define variables for objective losers and winners based on these predicted probabilities
			* losers -> 20% with the highest probality to self-categorize as globalization LOSERS based on their structural characteristics
			* winners -> 20% with the highest probality to self-categorize as globalization WINNERS based on their structural characteristics
			* middle -> neither losers nor winners (but not missing value)
	
		* compute quintiles for loser and winner probability
			egen predloserquintiles = xtile(loserprob), nq(5)
			egen predwinnerquintiles = xtile(winnerprob), nq(5)

		* define variables for objective losers and winners based on these predicted probabilities
			* rest/mid-point
			gen objectiveLoGvsWoG=1 if predloserquintiles<. & predwinnerquintiles<.
			* loser
			replace objectiveLoGvsWoG=0 if predloserquintiles==5
			* winner 
			replace objectiveLoGvsWoG=2 if predwinnerquintiles==5
				
		* label
			label define objectiveLoGvsWoG 0 "objective loser" 1 "middle" 2 "objective winner"
			label values objectiveLoGvsWoG objectiveLoGvsWoG
				
		* Write table 1
			tab objectiveLoGvsWoG globwin_cat, row 
	
		* Generate a 9-fold typology of subjective and objective globalization losers and winners
			gen glob_typology=0 if objectiveLoGvsWoG==0 & globwin_cat==0 
			replace glob_typology=1 if objectiveLoGvsWoG==0 & globwin_cat==1 
			replace glob_typology=2 if objectiveLoGvsWoG==0 & globwin_cat==2 
			replace glob_typology=3 if objectiveLoGvsWoG==1 & globwin_cat==0 
			replace glob_typology=4 if objectiveLoGvsWoG==1 & globwin_cat==1 
			replace glob_typology=5 if objectiveLoGvsWoG==1 & globwin_cat==2 
			replace glob_typology=6 if objectiveLoGvsWoG==2 & globwin_cat==0 
			replace glob_typology=7 if objectiveLoGvsWoG==2 & globwin_cat==1 
			replace glob_typology=8 if objectiveLoGvsWoG==2 & globwin_cat==2 
			
	
**# Bookmark #6	
*************************************************************************************				
************ Issue attitudes among globalization losers vs. winners *****************
*************************************************************************************

***** Figure 5: Issue attitudes (mean indices) of globalization losers vs. winners *****
	twoway (kdensity globecon_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globecon_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globecon_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			text(2.3 0.1 "winner", color(navy)) ///
			text(0.3 0.3 "loser", color(orange_red)) ///
			text(2.44 0.6 "midpoint", color(gs10)) ///
			title(Economic globalization) ///
			name(econglob_subj, replace) nodraw

	twoway (kdensity EUunificationtoofar_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity EUunificationtoofar_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity EUunificationtoofar_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title(European integration) ///
			name(EU_subj, replace) nodraw

	twoway (kdensity globimmi_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globimmi_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globimmi_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title(Immigration) ///
			name(immigration_subj, replace) nodraw
			
	twoway (kdensity redistribution_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity redistribution_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity redistribution_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title("Redistribution") ///
			name(redistribution_subj, replace) nodraw
				
	graph combine econglob_subj EU_subj immigration_subj redistribution_subj, row(1) imargin(tiny) ///
			ycommon title("Self-categorized winners and losers of globalization") name(subj, replace) nodraw

	twoway (kdensity globecon_mean if objectiveLoGvsWoG==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globecon_mean if objectiveLoGvsWoG==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globecon_mean if objectiveLoGvsWoG==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			text(2.1 0.1 "winner", color(navy)) ///
			text(0.3 0.25 "loser", color(orange_red)) ///
			text(2.3 0.5 "middle", color(gs10)) ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(Economic globalization) ///
			name(econglob_obj, replace) nodraw

	twoway (kdensity EUunificationtoofar_mean if objectiveLoGvsWoG==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity EUunificationtoofar_mean if objectiveLoGvsWoG==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity EUunificationtoofar_mean if objectiveLoGvsWoG==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(European integration) ///
			name(EU_obj, replace) nodraw

	twoway (kdensity globimmi_mean if objectiveLoGvsWoG==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globimmi_mean if objectiveLoGvsWoG==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globimmi_mean if objectiveLoGvsWoG==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(Immigration) ///
			name(immigration_obj, replace) nodraw
			
	twoway (kdensity redistribution_mean if objectiveLoGvsWoG==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity redistribution_mean if objectiveLoGvsWoG==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity redistribution_mean if objectiveLoGvsWoG==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title("Redistribution") ///
			name(redistribution_obj, replace) nodraw
		
	graph combine econglob_obj EU_obj immigration_obj redistribution_obj, row(1) imargin(tiny) ///
			ycommon title("Winners and losers of globalization based on socio-structural characteristics") name(obj, replace) nodraw		
			
	graph combine subj obj, ycommon col(1) imargin(tiny) iscale(*1.6) name(Figure5, replace)
		graph export "Figure5.pdf", replace
	
	
***** Appendix D: Additional results for issue positions of losers/winners *****
	*** Table D2: Principal component factor analysis of issue items used for Figure 5
		factor marketintegrationnot_std restrictimports_std foreigncompaniesnotinvest_std EUunificationtoofar_std EUunificationtoofar_w7_std EUunificationtoofar_w6_std  ///
				restrictimmigration_std refugeelimit_std econrefugeesdeport_std foreignersassimilate_std moresocialservices_std reduceincomediffs_std richhighertaxes_std, pcf
		rotate, promax blank(.4)

		predict EUunificationtoofar_factor globimmi_factor globecon_factor redistribution_factor
		
		* correlation between these factor scores
		pwcorr globecon_factor EUunificationtoofar_factor globimmi_factor redistribution_factor
	

	*** Figure D1: Issue attitudes of globalization losers vs. winners (don't know included for self-categorization)
		twoway (kdensity globecon_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
				(kdensity globecon_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
				(kdensity globecon_mean if globwin_cat==.b ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gold) lpattern(dash)) ///			 
				(kdensity globecon_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				text(2.3 0.1 "winner", color(navy)) ///
				text(0.3 0.3 "loser", color(orange_red)) ///
				text(2.0 0.83 "don't know", color(gold)) ///
				text(2.44 0.6 "midpoint", color(gs10)) ///
				title(Economic globalization) ///
				name(econglob_subj, replace) nodraw

		twoway (kdensity EUunificationtoofar_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
				(kdensity EUunificationtoofar_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
				(kdensity EUunificationtoofar_mean if globwin_cat==.b ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gold) lpattern(dash)) ///	
				(kdensity EUunificationtoofar_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title(European integration) ///
				name(EU_subj, replace) nodraw

		twoway (kdensity globimmi_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
				(kdensity globimmi_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
				(kdensity globimmi_mean if globwin_cat==.b ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gold) lpattern(dash)) ///				 
				(kdensity globimmi_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title(Immigration) ///
				name(immigration_subj, replace) nodraw
				
		twoway (kdensity redistribution_mean if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
				(kdensity redistribution_mean if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
				(kdensity redistribution_mean if globwin_cat==.b ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gold) lpattern(dash)) ///	
				(kdensity redistribution_mean if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title("Redistribution") ///
				name(redistribution_subj, replace) nodraw
					
		graph combine econglob_subj EU_subj immigration_subj redistribution_subj, row(1) imargin(tiny) ///
				ycommon title("Self-categorized winners and losers of globalization") name(subj, replace) nodraw	
				
		graph combine subj obj, ycommon col(1) imargin(tiny) iscale(*1.6) name(FigureD1, replace)
	
	*** Figure D2: Issue attitudes (factor scores instead of mean indices) of globalization losers vs. winners
		twoway (kdensity globecon_factor if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity globecon_factor if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity globecon_factor if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				text(0.4 -3 "winner", color(navy)) ///
				text(0.4 2.5 "loser", color(orange_red)) ///
				text(0.5 0 "midpoint", color(gs10)) ///
				title(Economic globalization) ///
				name(econglob_subj, replace) nodraw

		twoway (kdensity EUunificationtoofar_factor if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity EUunificationtoofar_factor if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity EUunificationtoofar_factor if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title(European integration) ///
				name(EU_subj, replace) nodraw

		twoway (kdensity globimmi_factor if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity globimmi_factor if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity globimmi_factor if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title(Immigration) ///
				name(immigration_subj, replace) nodraw
				
		twoway (kdensity redistribution_factor if globwin_cat==2 & objectiveLoGvsWoG<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity redistribution_factor if globwin_cat==0 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity redistribution_factor if globwin_cat==1 & objectiveLoGvsWoG<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				title("Redistribution") ///
				name(redistribution_subj, replace) nodraw
					
		graph combine econglob_subj EU_subj immigration_subj redistribution_subj, row(1) imargin(tiny) ///
				ycommon title("Self-categorized winners and losers of globalization") name(subj, replace) nodraw

		twoway (kdensity globecon_factor if objectiveLoGvsWoG==2 & globwin_cat<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity globecon_factor if objectiveLoGvsWoG==0 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity globecon_factor if objectiveLoGvsWoG==1 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				text(0.4 -3 "winner", color(navy)) ///
				text(0.4 2.5 "loser", color(orange_red)) ///
				text(0.5 0 "middle", color(gs10)) ///
				ylabel(0 (.2) .6, gmax gmin) ///
				title(Economic globalization) ///
				name(econglob_obj, replace) nodraw

		twoway (kdensity EUunificationtoofar_factor if objectiveLoGvsWoG==2 & globwin_cat<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity EUunificationtoofar_factor if objectiveLoGvsWoG==0 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity EUunificationtoofar_factor if objectiveLoGvsWoG==1 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				ylabel(0 (.2) .6, gmax gmin) ///
				title(European integration) ///
				name(EU_obj, replace) nodraw

		twoway (kdensity globimmi_factor if objectiveLoGvsWoG==2 & globwin_cat<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity globimmi_factor if objectiveLoGvsWoG==0 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity globimmi_factor if objectiveLoGvsWoG==1 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				ylabel(0 (.2) .6, gmax gmin) ///
				title(Immigration) ///
				name(immigration_obj, replace) nodraw
				
		twoway (kdensity redistribution_factor if objectiveLoGvsWoG==2 & globwin_cat<. ///
				[fweight=voteweight_mult], bwidth(0.3) lcolor(navy)) ///
				(kdensity redistribution_factor if objectiveLoGvsWoG==0 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(orange_red)) ///
				(kdensity redistribution_factor if objectiveLoGvsWoG==1 & globwin_cat<. ///
				 [fweight=voteweight_mult], bwidth(0.3) lcolor(gs10) lpattern(dash)), ///
				legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
				ylabel(0 (.2) .6, gmax gmin) ///
				title("Redistribution") ///
				name(redistribution_obj, replace) nodraw		
			
		graph combine econglob_obj EU_obj immigration_obj redistribution_obj, row(1) imargin(tiny) ///
				ycommon title("Winners and losers of globalization based on socio-structural characteristics") name(obj, replace) nodraw		
				
		graph combine subj obj, ycommon col(1) imargin(tiny) iscale(*1.66) name(FigureD2, replace)
		
		
	*** Figure D3: Issue attitudes by self-categorization as globalization loser vs. winner (single items)
		ciplot globalizationbad_std, by(globwin_cat) name(gr1, replace) title("Globalization is not good", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

		ciplot marketintegrationnot_std, by(globwin_cat) name(gr2, replace) title("Against market integration", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

		ciplot restrictimports_std, by(globwin_cat) name(gr3, replace) title("Restrict imports", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

		ciplot foreigncompaniesnotinvest_std, by(globwin_cat) name(gr4, replace) title("Against foreign investment", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

			
		ciplot EUunificationtoofar_std, by(globwin_cat) name(gr5, replace) title("EU unification too far (w8)", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw


		ciplot restrictimmigration_std, by(globwin_cat) name(gr6, replace) title("Immigration should be restricted", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot refugeelimit_std, by(globwin_cat) name(gr7, replace) title("Upper limit on refugees", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot econrefugeesdeport_std, by(globwin_cat) name(gr8, replace) title("Deport economic refugees", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot foreignersassimilate_std, by(globwin_cat) name(gr9, replace) title("Foreigners should assimilate", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

		ciplot moresocialservices_std, by(globwin_cat) name(gr10, replace) title("Higher welfare benefits & taxes", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot reduceincomediffs_std , by(globwin_cat) name(gr11, replace) title("Reduce income differences", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot richhighertaxes_std, by(globwin_cat) name(gr12, replace) title("Rich should pay higher taxes", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw

		ciplot Growthoverclimate_std, by(globwin_cat) name(gr13, replace) title("Growth over climate protection", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot Securityoverprivacy_std, by(globwin_cat) name(gr14, replace) title("Combat terrorism vs. privacy", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw
		ciplot nohomoadoption_std , by(globwin_cat) name(gr15, replace) title("Homosexuals not allowed to adopt", size(small)) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero)) ///
				msymbol(p) mcolor(black) ylabel(0.2 (0.2) 0.8) nodraw


		graph combine gr1 gr2 gr3 gr4 gr5 gr6 gr7 gr8 gr9 gr10 gr11 gr12 gr13 gr14 gr15, ycommon col(3) iscale(*1.65) imargin(zero) ysize(7) name(FigureD3, replace)


**# Bookmark #7	
*************************************************************************************				
************ Voting intentions among globalization losers vs. winners ***************
*************************************************************************************		
	
***** Descriptive statements in the text *****
	* Shares among those with an intention to vote
	tab voteint_w9_ord if globwin_cat==0 & voteint_w9_ord!=8 [fweight=voteweight_mult]
			// -> Of those self-categorized losers with an intention to vote about a third opt for the AfD (33%).

	* Self-categorization among AfD voters
	tab globwin_cat if voteint_w9_ord==6 [fweight=voteweight_mult]
			// -> Almost half of all AfD supporters self-categorize as losers of globalization (45%). 	


***** Descriptive: Figure 6: Vote intention by subjective (self-categorized) and objective loser/winner status *****
	tab voteint_w9_ord globwin_cat if voteweight_mult!=. & objectiveLoGvsWoG<.
			
	hist voteint_w9_ord if globwin_cat==0 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: loser") name(subjloser, replace)	nodraw
				
	hist voteint_w9_ord if globwin_cat==2 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: winner") name(subjwinner, replace) nodraw

	hist voteint_w9_ord if globwin_cat==1 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: midpoint") name(subjmid, replace) nodraw

	tab voteint_w9_ord objectiveLoGvsWoG if voteweight_mult!=. & globwin_cat<.
				
	hist voteint_w9_ord if objectiveLoGvsWoG==0 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Objective: loser") name(objloser, replace) nodraw

	hist voteint_w9_ord if objectiveLoGvsWoG==2 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Objective: winner") name(objwinner, replace) nodraw

	hist voteint_w9_ord if objectiveLoGvsWoG==1 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Objective: middle") name(objmid, replace) nodraw
				
	graph combine subjloser subjmid subjwinner objloser objmid objwinner, ycommon col(3) imargin(zero) iscale(*1.8) note("n=8,175", pos(5)) name(Figure6, replace)
		graph export "Figure6.pdf", replace


	***** For Appendix E: Additional results for voting intentions of losers/winners *****
	*** Figure E1: Vote intention by subjective (self-categorized) and objective loser/winner status (nine-fold typology)
		hist voteint_w9_ord if glob_typology==0 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(orange_red) ///
			xtitle(" ", size(zero)) ///
			title("Objective loser & subjective loser") name(gr1, replace) nodraw	
		hist voteint_w9_ord if glob_typology==1 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(gs10) ///
			xtitle(" ", size(zero)) ///
			title("Objective loser & subjective middle") name(gr2, replace)	nodraw
		hist voteint_w9_ord if glob_typology==2 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(navy) ///
			xtitle(" ", size(zero)) ///
			title("Objective loser & subjective winner") name(gr3, replace)	nodraw
		hist voteint_w9_ord if glob_typology==3 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(orange_red) ///
			xtitle(" ", size(zero)) ///
			title("Objective middle & subjective loser") name(gr4, replace)	nodraw
		hist voteint_w9_ord if glob_typology==4 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(gs10) ///
			xtitle(" ", size(zero)) ///
			title("Objective middle & subjective middle") name(gr5, replace) nodraw	
		hist voteint_w9_ord if glob_typology==5 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(navy) ///
			xtitle(" ", size(zero)) ///
			title("Objective middle & subjective winner") name(gr6, replace) nodraw		
		hist voteint_w9_ord if glob_typology==6 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(orange_red) ///
			xtitle(" ", size(zero)) ///
			title("Objective winner & subjective loser") name(gr7, replace)	nodraw
		hist voteint_w9_ord if glob_typology==7 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(gs10) ///
			xtitle(" ", size(zero)) ///
			title("Objective winner & subjective middle") name(gr8, replace) nodraw	
		hist voteint_w9_ord if glob_typology==8 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
			discrete percent ///
			xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
			color(navy) ///
			xtitle(" ", size(zero)) ///
			title("Objective winner & subjective winner") name(gr9, replace) nodraw		

		graph combine gr1 gr2 gr3 gr4 gr5 gr6 gr7 gr8 gr9, ycommon col(3) imargin(zero) iscale(*1.1) note("n=8,175", pos(5)) name(FigureE1, replace)
			
	
		
***** Vote intention: Regressions *****
	*** Figure 7: Vote probabilities by self-categorization as globalization loser vs. winner
	* define set of control variables
	global controls "i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 local_index_st"

	* hold observations constant 
	 reg voteint_w9_numb i.globwin_cat $controls i.subjclass i.subjdeprivation voteweight
		capture drop include
		gen include=1 if e(sample)													
		sum include	

	*** Run regressions and compute predicted probabilities
	* socio-demographic only, without glob. winner/loser
	mlogit voteint_w9_numb $controls [pweight=voteweight] if include==1
		fitstat
		eststo m0		

	* only sociodemographic controls
	mlogit voteint_w9_numb ib2.globwin_cat $controls [pweight=voteweight] if include==1
		fitstat
		eststo m1

	forvalues p = 1/7 {
				estimate restore m1
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_A_`p'
				}	
				
	* + subjective deprivation
	mlogit voteint_w9_numb i.globwin_cat $controls i.subjdeprivation [pweight=voteweight] if include==1
		fitstat
		eststo m2

	forvalues p = 1/7 {
				estimate restore m2
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_B_`p'
				}	
			
	* + control for subjective class
	mlogit voteint_w9_numb i.globwin_cat $controls i.subjdeprivation i.subjclass [pweight=voteweight] if include==1
		fitstat
		eststo m3

	forvalues p = 1/7 {
				estimate restore m3
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_C_`p'
				}		

	* plot
	coefplot AME_A_1 AME_B_1 AME_C_1 || AME_A_2 AME_B_2 AME_C_2 || AME_A_3 AME_B_3 AME_C_3 || AME_A_4 AME_B_4 AME_C_4 || AME_A_5 AME_B_5 AME_C_5 || AME_A_6 AME_B_6 AME_C_6, ///  
				bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD") subtitle( , size(small)) ///
				coeflabel(1._at="glob. loser" 2._at="midpoint" 3._at="glob. winner") ///
				level(95 85) ///
				xlabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4", gmax gmin) ///
				msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*2) mlabsize(vsmall) ///
				scheme(plottig) legend(rows(3) size(vsmall) order(3 "M1: socio-demographic controls" 6 "M2: + subjective deprivation" 9 "M3: + subjective class")) ///
				byopts(note("n=7,677", size(tiny) pos(5)))  ///
				xsize(5) name(vote_mlog, replace) nodraw
	 
	graph combine vote_mlog, iscale(*1.5) graphregion(margin(zero)) plotregion(margin(zero)) name(Figure7, replace) xsize(5.5)
		graph export "Figure7.pdf", replace

	
	***** For Appendix E: Additional results for voting intentions of losers/winners *****
		
	*** Marginal effects on vote choice from regressions with/without self-categorization as globalization loser vw. winner  

		* Figure E2: Average marginal effects on vote intention for the CDU/CSU
			* Model 0
			estimate restore m0
			margins, dydx(*) predict(outcome(1)) post
			estimate store AME0_UNION

			* Model 1
			estimate restore m1
			margins, dydx(*) predict(outcome(1)) post
			estimate store AME1_UNION		
		
			* plot
			coefplot AME0_UNION || AME1_UNION, level(95 85) xlabel(-0.3 (0.1) 0.2) ///
			baselevels msymbol(+) mcolor(orange_red) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			coeflabels(0.globwin_cat="globalization loser" 1.globwin_cat="midpoint (globalization)" 2.globwin_cat="globalization winner") ///
			xsize(4.5) xline(0) bylabels("w/o self-categorization" "with self-categorization") ysize(6)	name(FigureE2, replace)	

	
		* Figure E3: Average marginal effects on vote intention for the AfD
			* Model 0
			estimate restore m0
			margins, dydx(*) predict(outcome(6)) post
			estimate store AME0_AfD

			* Model 1
			estimate restore m1
			margins, dydx(*) predict(outcome(6)) post
			estimate store AME1_AfD		
		
			* plot
			coefplot AME0_AfD || AME1_AfD, cismooth(color(blue)) xlabel(-0.1 (0.1) 0.3) ///
			baselevels msymbol(+) mcolor(orange_red) mlabel mlabformat(%9.2f) mlabposition(12) mlabgap(*0.2) mlabsize(vsmall) ///
			coeflabels(0.globwin_cat="globalization loser" 1.globwin_cat="midpoint (globalization)" 2.globwin_cat="globalization winner") ///
			xsize(4.5) xline(0) bylabels("w/o self-categorization" "with self-categorization") ysize(6)	name(FigureE3, replace)	
			
	
	*** Figure E4: Predicted vote probabilities by subjective deprivation
		forvalues p = 1/7 {
					estimate restore m3
					margins, at(subjdeprivation=(1 2 3 4)) predict(outcome(`p')) post
					estimate store AME_D_`p'
					}		
		
		coefplot AME_D_1 || AME_D_2 || AME_D_3 || AME_D_4 || AME_D_5 || AME_D_6, ///  
					bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD" ) ///
					coeflabel(1._at="more" 2._at="fair share" 3._at="bit less" 4._at="lot less") ///
					level(95 85) ///
					xlabel(0 (0.1) 0.4, gmax gmin) ///
					msymbol(+) mlabel mlabformat(%9.2f) mlabposition(3) mlabgap(*2.2) mlabsize(vsmall) ///
					scheme(plottig) xsize(5) name(mlogit_subjdepr, replace) nodraw
		
		graph combine mlogit_subjdepr, iscale(*1.8) ///
			graphregion(margin(zero)) plotregion(margin(zero)) name(FigureE4, replace)

				
	*** Figure E5: Predicted vote probabilities by subjective social class
		forvalues p = 1/7 {
					estimate restore m3
					margins, at(subjclass=(0 1 2 3)) predict(outcome(`p')) post
					estimate store AME_E_`p'
					}		
		
		coefplot AME_E_1 || AME_E_2 || AME_E_3 || AME_E_4 || AME_E_5 || AME_E_6, ///  
			bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD" ) ///
			coeflabel(1._at="lower and working class" 2._at="lower middle class" 3._at="middle class" 4._at="upper (middle) class") ///
			level(95 85) ///
			xlabel(0 (0.1) 0.4, gmax gmin) ///
			msymbol(+) mlabel mlabformat(%9.2f) mlabposition(3) mlabgap(*1.5) mlabsize(vsmall) ///
			scheme(plottig) legend(off) xsize(5) name(mlogit_class, replace) nodraw

		graph combine mlogit_class, iscale(*1.8) ///
				graphregion(margin(zero)) plotregion(margin(zero)) name(FigureE5, replace)
	
		
		* Compare bivariate models: Subjective globalization vs. subjective deprivation vs. subjective class
			mlogit voteint_w9_numb i.globwin_cat [pweight=voteweight] if include==1
			mlogit voteint_w9_numb i.subjdeprivation [pweight=voteweight] if include==1
			mlogit voteint_w9_numb i.subjclass [pweight=voteweight] if include==1	
	
	
	*** Figure E6: Vote intention by subjective (self-categorized; with don't know included) and objective loser/winner status
		tab globwin_catDK voteint_w9_ord
		
		hist voteint_w9_ord if globwin_cat==.b [fweight=voteweight_mult], ///
					discrete percent ///
					xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
					color(gold) ///
					xtitle(" ", size(zero)) /// 
					title("Subjective: don't know") name(subjDK, replace) nodraw	
		
		graph combine subjloser subjmid subjwinner subjDK objloser objmid objwinner, ycommon col(4) imargin(zero) iscale(*1.5) note("n=10,624", pos(5)) name(FigureE6, replace)
	

	*** Figure E7: Vote probabilities by self-categorization as globalization loser vs. winner (with don't know included)
		* define set of control variables
		global controls "i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 local_index_st"

		* hold observations constant 
		 reg voteint_w9_numb i.globwin_catDK $controls i.subjclass i.subjdeprivation voteweight
			capture drop include
			gen include=1 if e(sample)													
			sum include	
			
		* socio-demographic only, without glob. winner/loser
		mlogit voteint_w9_numb $controls [pweight=voteweight] if include==1
			fitstat
			eststo m0		

		* only sociodemographic controls
		mlogit voteint_w9_numb ib2.globwin_catDK $controls [pweight=voteweight] if include==1
			fitstat
			eststo m1

		forvalues p = 1/7 {
					estimate restore m1
					margins, at(globwin_catDK=(0 1 3 2)) predict(outcome(`p')) post
					estimate store AME_A_`p'
					}	
						
		* + subjective deprivation
		mlogit voteint_w9_numb i.globwin_catDK $controls i.subjdeprivation [pweight=voteweight] if include==1
			fitstat
			eststo m2

		forvalues p = 1/7 {
					estimate restore m2
					margins, at(globwin_catDK=(0 1 3 2)) predict(outcome(`p')) post
					estimate store AME_B_`p'
					}	
					
		* + control for subjective class
		mlogit voteint_w9_numb i.globwin_catDK $controls i.subjdeprivation i.subjclass [pweight=voteweight] if include==1
			fitstat
			eststo m3

		forvalues p = 1/7 {
					estimate restore m3
					margins, at(globwin_catDK=(0 1 3 2)) predict(outcome(`p')) post
					estimate store AME_C_`p'
					}		

		* plot
		coefplot AME_A_1 AME_B_1 AME_C_1 || AME_A_2 AME_B_2 AME_C_2 || AME_A_3 AME_B_3 AME_C_3 || AME_A_4 AME_B_4 AME_C_4 || AME_A_5 AME_B_5 AME_C_5 || AME_A_6 AME_B_6 AME_C_6, ///  
					bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD") subtitle( , size(small)) ///
					coeflabel(1._at="glob. loser" 2._at="midpoint" 3._at="don't know" 4._at="glob. winner") ///
					level(95 85) ///
					xlabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4", gmax gmin) ///
					msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*2) mlabsize(vsmall) ///
					scheme(plottig) legend(rows(3) size(vsmall) order(3 "M1: socio-demographic controls" 6 "M2: + subjective deprivation" 9 "M3: + subjective class")) ///
					byopts(note("n=8,980", size(tiny) pos(5)))  ///
					xsize(5) name(vote_mlog_withDK, replace) nodraw
		 
		graph combine vote_mlog_withDK, iscale(*1.3) graphregion(margin(zero)) plotregion(margin(zero)) name(FigureE7, replace) xsize(5.5)
		

	*** Figure E8: Vote probabilities by self-categorization as globalization loser vs. winner (1 to 7 scale as categorical)
		* define set of control variables
		global controls "i.female i.agegroup i.east i.unemployment ib6.educat ib6.incomecat ib9.occupclass ib14.sector2 local_index_st"

		* hold observations constant 
		 reg voteint_w9_numb i.globwin $controls i.subjclass i.subjdeprivation voteweight
			capture drop include
			gen include=1 if e(sample)													
			sum include	

		* socio-demographic only, without glob. winner/loser
		mlogit voteint_w9_numb $controls [pweight=voteweight] if include==1
			fitstat
			eststo m0		

		* only sociodemographic controls
		mlogit voteint_w9_numb i.globwin $controls [pweight=voteweight] if include==1
			fitstat
			eststo m1

		forvalues p = 1/7 {
					estimate restore m1
					margins, at(globwin=(1 2 3 4 5 6 7)) predict(outcome(`p')) post
					estimate store AME_A_`p'
					}	
					
		* + subjective deprivation
		mlogit voteint_w9_numb i.globwin $controls i.subjdeprivation [pweight=voteweight] if include==1
			fitstat
			eststo m2

		forvalues p = 1/7 {
					estimate restore m2
					margins, at(globwin=(1 2 3 4 5 6 7)) predict(outcome(`p')) post
					estimate store AME_B_`p'
					}	
					
		* + control for subjective class
		mlogit voteint_w9_numb i.globwin $controls i.subjdeprivation i.subjclass [pweight=voteweight] if include==1
			fitstat
			eststo m3

		forvalues p = 1/7 {
					estimate restore m3
					margins, at(globwin=(1 2 3 4 5 6 7)) predict(outcome(`p')) post
					estimate store AME_C_`p'
					}		

		* plot
		coefplot AME_A_1 AME_B_1 AME_C_1 || AME_A_2 AME_B_2 AME_C_2 || AME_A_3 AME_B_3 AME_C_3 || AME_A_4 AME_B_4 AME_C_4 || AME_A_5 AME_B_5 AME_C_5 || AME_A_6 AME_B_6 AME_C_6, ///  
					bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD") subtitle( , size(small)) ///
					coeflabel(1._at="glob. loser" 2._at="2" 3._at="3" 4._at="4" 5._at="5" 6._at="6" 7._at="glob. winner") ///
					level(95 85) ///
					xlabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5", gmax gmin) ///
					msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*4) mlabsize(vsmall) ///
					scheme(plottig) legend(rows(3) size(vsmall) order(3 "M1: socio-demographic controls" 6 "M2: + subjective deprivation" 9 "M3: + subjective class")) ///
					byopts(note("n=8,980", size(tiny) pos(5)))  ///
					xsize(3.5) name(vote_mlog_with1to7, replace) nodraw
		 
		graph combine vote_mlog_with1to7, iscale(*1.0) graphregion(margin(zero)) plotregion(margin(zero)) name(FigureE8, replace) xsize(3.5)

		
**# Bookmark #8		
**************************************************************************************************			
***************** Appendix F: Results for re-called vote choices of losers/winners ***************
**************************************************************************************************		
	
	*** Figure F1: Recalled vote choice in 2017 federal election by globalization loser vs. winner (nonvoters excluded)
	tab voterecall_num globwin_cat if voteweight_mult!=. & objectiveLoGvsWoG<.

	hist voterecall_num if globwin_cat==0 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: loser") name(subjloser, replace) nodraw

	hist voterecall_num if globwin_cat==2 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: winner") name(subjwinner, replace) nodraw

	hist voterecall_num if globwin_cat==1 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: midpoint") name(subjmid, replace) nodraw

	tab voterecall_num objectiveLoGvsWoG if voteweight_mult!=. & globwin_cat<.
				
	hist voterecall_num if objectiveLoGvsWoG==0 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Objective: loser") name(objloser, replace) nodraw

	hist voterecall_num if objectiveLoGvsWoG==2 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Objective: winner") name(objwinner, replace) nodraw

	hist voterecall_num if objectiveLoGvsWoG==1 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/7, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Objective: middle") name(objmid, replace) nodraw
				
	graph combine subjloser subjmid subjwinner objloser objmid objwinner, ycommon col(3) imargin(zero) iscale(*1.8) note("n=8,458", pos(5)) name(FigureF1, replace)


	*** Figure F2: Recalled vote choice in 2017 federal election by globalization loser vs. winner (nonvoters included)		
	tab voterecall2_num globwin_cat if voteweight_mult!=. & objectiveLoGvsWoG<.

	hist voterecall2_num if globwin_cat==0 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: loser") name(subjloser, replace) nodraw

	hist voterecall2_num if globwin_cat==2 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: winner") name(subjwinner, replace) nodraw

	hist voterecall2_num if globwin_cat==1 & objectiveLoGvsWoG<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: midpoint") name(subjmid, replace) nodraw

	tab voterecall2_num objectiveLoGvsWoG if voteweight_mult!=. & globwin_cat<.
				
	hist voterecall2_num if objectiveLoGvsWoG==0 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(orange_red) ///
				xtitle(" ", size(zero)) ///
				title("Objective: loser") name(objloser, replace) nodraw

	hist voterecall2_num if objectiveLoGvsWoG==2 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(navy) ///
				xtitle(" ", size(zero)) ///
				title("Objective: winner") name(objwinner, replace) nodraw

	hist voterecall2_num if objectiveLoGvsWoG==1 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				color(gs10) ///
				xtitle(" ", size(zero)) ///
				title("Objective: middle") name(objmid, replace) nodraw
				
	graph combine subjloser subjmid subjwinner objloser objmid objwinner, ycommon col(3) imargin(zero) iscale(*1.8) note("n=8,917", pos(5)) name(FigureF2, replace)

							
	*** Figure F3: Predicted vote probabilities (reported vote choice in 2017 federal election) by self-categorized globalization loser vs. winner
	* hold observations constant 
	 reg voterecall_num i.globwin_cat $controls i.subjclass i.subjdeprivation voteweight
		capture drop include
		gen include=1 if e(sample)													
		sum include	

	* socio-demogrpahic only, without glob. winner/loser
	mlogit voterecall_num $controls [pweight=voteweight] if include==1

	* only sociodemographic controls
	mlogit voterecall_num i.globwin_cat $controls [pweight=voteweight] if include==1
	eststo m1

	forvalues p = 1/7 {
				estimate restore m1
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_A_`p'
				}	
				
	* + subjective deprivation
	mlogit voterecall_num i.globwin_cat $controls i.subjdeprivation [pweight=voteweight] if include==1
	eststo m2

	forvalues p = 1/7 {
				estimate restore m2
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_B_`p'
				}	
				
	* + control for subjective class
	mlogit voterecall_num i.globwin_cat $controls i.subjdeprivation i.subjclass [pweight=voteweight] if include==1
	eststo m3

	forvalues p = 1/7 {
				estimate restore m3
				margins, at(globwin_cat=(0 1 2)) predict(outcome(`p')) post
				estimate store AME_C_`p'
				}		

	* plot
	coefplot AME_A_1 AME_B_1 AME_C_1 || AME_A_2 AME_B_2 AME_C_2 || AME_A_3 AME_B_3 AME_C_3 || AME_A_4 AME_B_4 AME_C_4 || AME_A_5 AME_B_5 AME_C_5 || AME_A_6 AME_B_6 AME_C_6, ///  
				bylabels("CDU/CSU" "Greens" "SPD" "FDP" "The Left" "AfD") subtitle( , size(small)) ///
				coeflabel(1._at="glob. loser" 2._at="midpoint" 3._at="glob. winner") ///
				level(95 85) ///
				xlabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4", gmax gmin) ///
				msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*1) mlabsize(vsmall) ///
				scheme(plottig) legend(rows(3) size(vsmall) order(3 "M1: socio-demographic controls" 6 "M2: + subjective deprivation" 9 "M3: + subjective class")) ///
				byopts(note("n=8,422", size(tiny) pos(5)))  ///
				xsize(5) name(voterecall_mlog, replace) nodraw
				
	graph combine voterecall_mlog, iscale(*1.5) graphregion(margin(zero)) plotregion(margin(zero)) xsize(5.5) name(FigureF3, replace)


**# Bookmark #9				
******************************************************************************************************************				
************** Appendix G: Subjective deprivation, subjective class, and self-categorization *********************
******************************************************************************************************************		

* Figure G1: Subjective deprivation by self-categorization as globalization loser vs. winner
	tab subjdeprivation globwin_cat

	hist subjdeprivation [fweight=voteweight_mult], by(globwin_cat, row(1) legend(off) note("n=9,839", size(vsmall) pos(5))) ///
		discrete percent xlabel(1/4, valuelabel angle(045)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
		legend(off) xtitle(" ", size(zero)) xsize(8) ///
		graphregion(margin(zero)) name(subjdepr, replace) nodraw	

	graph combine subjdepr, iscale(*1.5) graphregion(margin(zero)) plotregion(margin(zero)) name(FigureG1, replace)


* Figure G2: Subjective class membership by self-categorization as globalization loser vs. winner
	tab subjclass globwin_cat
	
	hist subjclass [fweight=voteweight_mult], by(globwin_cat, row(1) legend(off) note("n=9,660", size(vsmall) pos(5))) ///
		discrete percent xlabel(0/3, valuelabel angle(045)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
		legend(off) xtitle(" ", size(zero)) xsize(8) ///
		graphregion(margin(zero)) name(hist_class, replace) nodraw
		
	graph combine hist_class, iscale(*1.5) graphregion(margin(zero)) plotregion(margin(zero)) name(FigureG2, replace)			
						
			
**# Bookmark #10							
******************************************************************************************************************				
******************* Appendix H: Classifying objective globalization winners and losers - Alternative *************
******************************************************************************************************************									
*** Appendix: Alternative classification of objective winners and losers of globalization
	* Latent variable model for structural globalization loser vs winner
		* individual level: 			educat incomecat occupclass sector2
		* electoral-district level: 	local_index_st	

	* Prepare input variables
	fre educat incomecat occupclass sector2
	recode occupclass (0 1 2 3 4 10 = 0) (5 6 7 8 9  = 1), gen(occupclass_win)
	recode sector2 (1 2 3 4 5 6 7 = 0) (8 9 10 11 12 13 14 = 1), gen(sector_win)

	fre kp8_2880v
	clonevar globw8 = kp8_2880v


	* SEM with formative factor reflecting an objective latent loser-winner variable
	sem (GLOBWIN <- educat@1 incomecat occupclass_win sector_win local_index_st) ///
		(GLOBATT -> globw9@1 globw8) ///
		(GLOBWIN -> GLOBATT), var(e.GLOBWIN@0) standardized 


	* Predict factor scores
	predict globwin_fs globatt_fs if e(sample), latent


	* Coding of classification variable
	sum globwin_fs
	display r(min) 
	display r(max)
	gen globwin_fsr = (globwin_fs + -1*r(min)) / (-1*r(min) + r(max))
	sum globwin_fsr

	sum globwin_fsr

	egen p20 = pctile(globwin_fsr), p(20)
	egen p80 = pctile(globwin_fsr), p(80)

	gen globwin_fs_cat3 = .
	replace globwin_fs_cat3 = 2 if globwin_fsr > p80 & globwin_fsr <= 1
	replace globwin_fs_cat3 = 0 if globwin_fsr < p20 & globwin_fsr >= 0
	replace globwin_fs_cat3 = 1 if globwin_fsr >= p20 & globwin_fsr <= p80
	bysort globwin_fs_cat3: fre  globwin_fsr 
	fre globwin_fs_cat3

	tab globwin_fs_cat3 objectiveLoGvsWoG, mis
	tab globwin_fs_cat3 globwin_cat
	tab globwin_cat objectiveLoGvsWoG
	
	
*** TEXT: Correlation of alternative objective measures
	pwcorr globwin_fs objectiveLoGvsWoG

*** TEXT: Percentage of same classifications
	tab globwin_fs_cat3 objectiveLoGvsWoG, cell nof // 15 + 51 + 17 = 83

*** Table H2: Replication of Table 1 in main text
	tab globwin_fs_cat3 globwin_cat, row
	
*** Figure H2: Replication of Figure 5 in main text
	twoway (kdensity globecon_mean if globwin_cat==2 & globwin_fs_cat3<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globecon_mean if globwin_cat==0 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globecon_mean if globwin_cat==1 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			text(2.3 0.1 "winner", color(navy)) ///
			text(0.3 0.3 "loser", color(orange_red)) ///
			text(2.44 0.6 "midpoint", color(gs10)) ///
			title(Economic globalization) ///
			name(econglob_subj, replace) nodraw

	twoway (kdensity EUunificationtoofar_mean if globwin_cat==2 & globwin_fs_cat3<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity EUunificationtoofar_mean if globwin_cat==0 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity EUunificationtoofar_mean if globwin_cat==1 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title(European integration) ///
			name(EU_subj, replace) nodraw

	twoway (kdensity globimmi_mean if globwin_cat==2 & globwin_fs_cat3<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globimmi_mean if globwin_cat==0 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globimmi_mean if globwin_cat==1 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title(Immigration) ///
			name(immigration_subj, replace) nodraw
			
	twoway (kdensity redistribution_mean if globwin_cat==2 & globwin_fs_cat3<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity redistribution_mean if globwin_cat==0 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity redistribution_mean if globwin_cat==1 & globwin_fs_cat3<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			title("Redistribution") ///
			name(redistribution_subj, replace) nodraw
				
	graph combine econglob_subj EU_subj immigration_subj redistribution_subj, row(1) imargin(tiny) ///
			ycommon title("Self-categorized winners and losers of globalization") name(subj, replace) nodraw

	twoway (kdensity globecon_mean if globwin_fs_cat3==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globecon_mean if globwin_fs_cat3==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globecon_mean if globwin_fs_cat3==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			text(2.1 0.1 "winner", color(navy)) ///
			text(0.3 0.25 "loser", color(orange_red)) ///
			text(2.3 0.5 "middle", color(gs10)) ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(Economic globalization) ///
			name(econglob_obj, replace) nodraw

	twoway (kdensity EUunificationtoofar_mean if globwin_fs_cat3==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity EUunificationtoofar_mean if globwin_fs_cat3==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity EUunificationtoofar_mean if globwin_fs_cat3==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(European integration) ///
			name(EU_obj, replace) nodraw

	twoway (kdensity globimmi_mean if globwin_fs_cat3==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity globimmi_mean if globwin_fs_cat3==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity globimmi_mean if globwin_fs_cat3==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title(Immigration) ///
			name(immigration_obj, replace) nodraw
			
	twoway (kdensity redistribution_mean if globwin_fs_cat3==2 & globwin_cat<. ///
			[fweight=voteweight_mult], bwidth(0.1) lcolor(navy)) ///
			(kdensity redistribution_mean if globwin_fs_cat3==0 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(orange_red)) ///
			(kdensity redistribution_mean if globwin_fs_cat3==1 & globwin_cat<. ///
			 [fweight=voteweight_mult], bwidth(0.1) lcolor(gs10) lpattern(dash)), ///
			legend(off) xtitle(" ", size(zero)) ytitle(" ", size(zero)) note(" ", size(zero))  ///
			ylabel(0 (.5) 2.5, gmax gmin) ///
			title("Redistribution") ///
			name(redistribution_obj, replace) nodraw
		
		
	graph combine econglob_obj EU_obj immigration_obj redistribution_obj, row(1) imargin(tiny) ///
			ycommon title("Winners and losers of globalization based on socio-structural characteristics") name(obj, replace) nodraw		
			
	graph combine subj obj, ycommon col(1) imargin(tiny) iscale(*1.66) name(FigureH2, replace)

			
*** Figure H3: Replication of Figure 6 in main text				
	tab voteint_w9_ord globwin_cat if voteweight_mult!=. & globwin_fs_cat3<.

	hist voteint_w9_ord if globwin_cat==0 & globwin_fs_cat3<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(orange_red) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: loser") name(subjloser, replace) nodraw

	hist voteint_w9_ord if globwin_cat==2 & globwin_fs_cat3<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(navy) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: winner") name(subjwinner, replace) nodraw

	hist voteint_w9_ord if globwin_cat==1 & globwin_fs_cat3<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(gs10) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Subjective: midpoint") name(subjmid, replace) nodraw

	tab voteint_w9_ord objectiveLoGvsWoG if voteweight_mult!=. & globwin_cat<.
				
	hist voteint_w9_ord if globwin_fs_cat3==0 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(orange_red) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Objective: loser") name(objloser, replace) nodraw

	hist voteint_w9_ord if globwin_fs_cat3==2 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(navy) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Objective: winner") name(objwinner, replace) nodraw

	hist voteint_w9_ord if globwin_fs_cat3==1 & globwin_cat<. [fweight=voteweight_mult], ///
				discrete percent ///
				color(gs10) ///
				xlabel(1/8, valuelabel angle(090)) addlabel addlabopts(yvarformat(%4.0f) mlabsize(small)) ///
				xtitle(" ", size(zero)) ///
				title("Objective: middle") name(objmid, replace) nodraw
				
	graph combine subjloser subjmid subjwinner objloser objmid objwinner, ycommon col(3) imargin(zero) iscale(*1.8) note("n=7,530", pos(5))										


**# Bookmark #11		
********************************************************************************	
*** Appendix I: Association between education, occupational class, and income **
********************************************************************************	

* Figure I1: Mean income by education and occupational class
	ciplot income_equi, by(educat) ytitle("equivalised household income") xlabel( , angle(45)) xtitle(" ") ///
		title("mean income by education") name(gr1, replace) nodraw
	ciplot income_equi, by(occupclass) ytitle("equivalised household income") xlabel( , angle(45)) xtitle(" ") ///
			title("mean income by occupational class") name(gr2,  replace) nodraw
		graph combine gr1 gr2, ycommon iscale(*1.4) name(FigureI1, replace)
	
* Table I1: Percentage shares of school education by occupational class
	tab occupclass educat, row nofreq 
	